<!DOCTYPE html>
<html>
  <head>
    <title>金额计算器</title>
    <script>
      function calculate() {
        var n0 = parseInt(document.getElementById("inputAmount").value);
        var result = 0;
        // 大于10w 小于  100亿
        if (n0 >= 100000 && n0 <= 10000000000) {
          // 小于50w
          if (n0 <= 500000) {
            result = (n0 - 100000) * 0.01;
          } else if (n0 <= 1000000) {
            result = (500000 - 100000) * 0.01 + (n0 - 500000) * 0.008;
          } else if (n0 <= 2000000) {
            result =
              (500000 - 100000) * 0.01 +
              (1000000 - 500000) * 0.008 +
              (n0 - 1000000) * 0.006;
          } else if (n0 <= 5000000) {
            result =
              (500000 - 100000) * 0.01 +
              (1000000 - 500000) * 0.008 +
              (2000000 - 1000000) * 0.006 +
              (n0 - 2000000) * 0.004;
          } else if (n0 <= 10000000) {
            result =
              (500000 - 100000) * 0.01 +
              (1000000 - 500000) * 0.008 +
              (2000000 - 1000000) * 0.006 +
              (5000000 - 2000000) * 0.004 +
              (n0 - 5000000) * 0.002;
          } else {
            result =
              (500000 - 100000) * 0.01 +
              (1000000 - 500000) * 0.008 +
              (2000000 - 1000000) * 0.006 +
              (5000000 - 2000000) * 0.004 +
              (10000000 - 5000000) * 0.002 +
              (n0 - 10000000) * 0.001;
          }
        } else {
          document.getElementById("result").innerHTML =
            "请输入正确的金额范围（10万到一百亿）！";
          return;
        }

        document.getElementById("result").innerHTML = "计算结果：" + result;
      }
    </script>
  </head>
  <body>
    <h1>金额计算器</h1>
    <input type="text" id="inputAmount" placeholder="请输入金额" />
    <button onclick="calculate()">计算</button>
    <p id="result">初始值：0</p>
  </body>
</html>
